{extend name="default/template/base_index" /}

{block name="area_header"}
<link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
<style>.pink{color:pink;}</style>
<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/cosmo-skin.css" />
<script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
{/block}

{block name="area_body"}
{include file="default/Widget/topbar" /}
<div class="admin-main container-fluid">
    {include file="default/Widget/left" /}
    <div class="admin-main-content">
        {include file="default/Widget/breadcrumb" /}
        <!-- 过滤\查询按钮 -->
        <div class="filter-controls">
            {:widget('OrgArea/area')}
            <!-- 日期查询 -->
            <form action="{:url('Buyorder/index')}" method="post" class="searchForm form-inline">
                <div class="form-group col-lg-12 col-md-12">
                    <div class="input-group">
                        <div class="input-group-addon input-sm">
                            时间
                            <i class="fa fa-calendar"></i>
                        </div>
                        <input type="text" name="startdatetime" id="startdatetime" class="form-control input-short input-sm" value="{$startdatetime}" />
                        <div class="input-group-addon input-sm">
                            <i class="fa fa-long-arrow-right"></i>
                        </div>
                        <input type="text" name="enddatetime" id="enddatetime" class="form-control input-short input-sm" value="{$enddatetime}" />
                    </div>
                    <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
                </div>
            </form>
        </div>
        <!-- 操作按钮 -->
        <div class="btn-controls">
        </div>
        <table class="table table-striped table table-hover  table-condensed">
            <thead>
            <tr>
                <th>
                    <input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');" />
                </th>
                <th>
                    订单编号
                </th>
                <th>
                    用户
                </th>
                <th>
                    商品
                </th>
                <th>
                    数量
                </th>
                <th>
                    上级
                </th>
                <th>
                    联系号码
                </th>
                <th>
                    总价格(元)
                </th>

                <th>
                    下单时间
                </th>
                <!--<th>-->
                <!--操作-->
                <!--</th>-->
            </tr>
            </thead>
            <tbody>
            {empty name="list"}
            <tr>
                <td colspan="10" class="text-center">{:L('NO_DATA')}</td>
            </tr>
            {else/}
            {volist name="list" id="vo"}
            <tr>
                <td>
                    <input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem" />
                </td>
                <td>
                    <a href="{:url('buyorder/detail',array('id'=>$vo['id']))}">{$vo.id}</a>
                </td>
                <td>
                    <a href="{:url('Member/view',array('id'=>$vo['uid']))}?ret_url=__SELF__">
                        <img class="m-avatar" src="{$vo['head']}" />
                        {empty name="vo.username"}
                        {else/}{$vo.username|default='--'}{/empty}
                    </a>
                </td>
                <td>
                    {$vo.name}
                </td>
                <td>
                    {$vo.count}
                </td>
                <td>
                    <a href="{:url('Member/view',array('id'=>$vo['goods_uid']))}?ret_url=__SELF__">
                        {empty name="vo.nickname"}
                        {$vo.goods_name|default='--'}
                        {else/}{$vo.nickname|default='--'}{/empty}
                    </a>
                </td>
                <td>
                    {$vo.mobile}
                </td>
                <td class="">
                    {:number_format($vo['money']/100,2,".","")}
                </td>
                <td>
                    {empty name="vo['create_time']"}
                    {else/} {$vo['create_time']}{/empty}

                </td>
            </tr>

            {/volist}
            {/empty}
            </tbody>
        </table>
        <div>{$show}</div>


        <script type="text/javascript">
            $(function() {
                $(".orderstatus").click(function(){
                    $(".searchForm").submit();
                });
                $(".commentstatus").click(function(){
                    $(".searchForm").submit();
                });
                $(".paystatus").click(function(){
                    $(".searchForm").submit();
                })

                $('#startdatetime').datetimepicker({
                    lang: 'ch',
                    format:'Y-m-d H:i:s',
                    // format:'Y-m-d',
                    // timepicker:false,
                });
                $('#enddatetime').datetimepicker({
                    lang: 'ch',
                    format:'Y-m-d H:i:s',
                });
            });
        </script>
    </div>
    <!-- END admin-main-content -->
</div>
<!-- END admin-main-->
{/block}

{block name="area_footer"}

<script src="__CDN__/select2/4.0.0/js/select2.min.js"></script>
<script src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
<script type="text/javascript">
    $(function(){
        $("#user_select2").select2({
            placeholder: "输入用户id或昵称查询"	,
            language: "zh-CN",
            ajax: {
                url: "{:url('Member/select')}",
                dataType: 'json',
                delay: 250,
                data: function (params) {
                    var queryParameters = {
                        q: params.term
                    }
                    return queryParameters;

                },
                processResults: function (data, page) {
                    if(!data.info){
                        data.info = new Array();
                        data.info['nodata']="无相关数据";
                    }
                    // parse the results into the format expected by Select2.
                    // since we are using custom formatting functions we do not need to
                    // alter the remote JSON data
                    return {
                        results: data.info
                    };
                },
                cache: true
            },
            minimumInputLength: 0,
            templateSelection: function (repo) {
                return repo.nickname || repo.text;
            },
            templateResult: function (repo) {

                if (repo.loading) return repo.text;
                if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                return $(markup);
            },
        });
    });
</script>

{/block}